package com.android.universydroid.framework;

import android.R.string;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import java.lang.String;

public class DBHelper extends SQLiteOpenHelper {

	public DBHelper(Context context, String name, CursorFactory factory, int version) {
		super(context, name, factory, version);
	}

	public DBHelper(Context context) {
		super(context, "UniversyDroid.db", null, 1);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		String sql = "CREATE TABLE IF NOT EXISTS [DISCIPLINA] (" +
				  "[CODIGO] AUTOINC NOT NULL, " +
				  "[NOME] VARCHAR2(70) NOT NULL, " +
				  "[DIA] INTEGER(1) NOT NULL, " +
				  "[SALA] VARCHAR2(10), " +
				  "[TERMINO] DATE NOT NULL, " +
				  "[PROFESSOR] VARCHAR2(100));" +


				"CREATE TABLE IF NOT EXISTS [CALENDARIO] (" +
				  "[CODIGO] AUTOINC NOT NULL, " +
				  "[CODIGO_TURMA] INTEGER NOT NULL CONSTRAINT [FK_DISC_CALEND] REFERENCES [DISCIPLINA]([CODIGO]), " +
				  "[DATA] DATE NOT NULL, " +
				  "[CONTEUDO] VARCHAR2(500), " +
				  "[TIPO_ATIVIDADE] VARCHAR2(200));" +


				"CREATE TABLE IF NOT EXISTS [LIVRO] (" +
				  "[CODIGO] AUTOINC NOT NULL, " + 
				  "[CODIGO_TURMA] INTEGER NOT NULL CONSTRAINT [FK_DISC_LIVRO] REFERENCES [DISCIPLINA]([CODIGO])," + 
				  "[TITULO] VARCHAR2(50) NOT NULL," + 
				  "[AUTOR] VARCHAR2(50) NOT NULL, " + 
				  "[EDITORA] VARCHAR2(100), " + 
				  "[ANO] INTEGER(4), " +
				  "[EDICAO] INTEGER(3));" +
				  

				"CREATE TABLE IF NOT EXISTS [CONFIG] (" +
				  "[CODIGO] AUTOINC NOT NULL, " +
				  "[NOME_ALUNO] VARCHAR2(500), " +
				  "[COD_CURSO] INTEGER, " +
				  "[NOME_CURSO] VARCHAR2(500), " +
				  "[PNE] BOOLEAN);";
		
		db.execSQL(sql);
	}

}